package com.konsung.ksdc.manager.appmain;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.githang.statusbar.StatusBarCompat;
import com.konsung.ksdc.R;
import com.konsung.ksdc.common.network.RequestCallback;
import com.konsung.ksdc.common.network.RequestUtils;
import com.konsung.ksdc.common.network.ResponseBean;
import com.konsung.ksdc.common.utils.StringUtils;
import com.konsung.ksdc.config.NetConfig;

import okhttp3.Call;

/**
 * Created by Administrator on 2016/3/28 0028.
 */
public abstract class BaseActivity extends FragmentActivity {

    protected String activityDesc = "";
    protected String beginDate = "";
    protected String endDate = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shopping_cart);
        beginDate = StringUtils.getDateStr();
    }

    @Override
    public void setContentView(int resId) {
        super.setContentView(resId);
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#45C01A"), true);
    }

    @Override
    protected void onResume() {
        super.onResume();
        beginDate = StringUtils.getDateStr();
    }

    /**
     * 显示界面
     * @return string
     */
    protected abstract String activityDesc();

    @Override
    protected void onStop() {
        super.onStop();
        endDate = StringUtils.getDateStr();
        activityDesc = activityDesc();
        commitOnStop();
    }

    /**
     * 用户数据习惯
     */
    protected void commitOnStop() {
        RequestUtils.commitUserData(activityDesc, NetConfig.currentEmpid,
                beginDate,
                endDate, "停留", new RequestCallback() {
                    @Override
                    public void onError(Call call, Exception e) {
                    }

                    @Override
                    public void onResponse(ResponseBean responseBean) {
                    }
                });
    }

}
